package com.desmao.controller;

import com.desmao.model.UserDetail;
import com.desmao.model.UserInfo;
import com.desmao.service.BaseService;
import com.desmao.service.UserDetailService;
import com.desmao.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TestDataSourceController {

//    @Autowired
//    private UserDetailService userDetailService;
//
//    @Autowired
//    private UserInfoService userInfoService;
    @Qualifier("userInfoService")
    @Autowired
    private BaseService<UserInfo,String> userInfoService;

    @Autowired
    private BaseService<UserDetail,String> baseService;

    @RequestMapping(value = "/test1", method = RequestMethod.GET)
    public List<UserInfo> selectUser() {
        System.out.println("查询第一个数据源");
        return  userInfoService.selectList();
    }

    @RequestMapping(value = "/test2", method = RequestMethod.GET)
    public List<UserDetail> userDetail() {
        System.out.println("查询第二个数据源");
        //return userDetailService.selectList();
        return baseService.selectList();
    }

}